package com.luo.chengrui.wordprint;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class RenderData {
    /**
     * 文本
     */
    private Map<String, String> textRenderData;
    /**
     * 图片
     */
    private Map<String, MyPicture> pictureRenderData;
    /**
     * 表格
     */
    private Map<String, List<Map<String, String>>> tableRenderData;

    public RenderData() {
        textRenderData = new HashMap<>();
        pictureRenderData = new HashMap<>();
        tableRenderData = new HashMap<>();
    }

    public Map<String, String> getTextRenderData() {
        return textRenderData;
    }

    public void setTextRenderData(Map<String, String> textRenderData) {
        this.textRenderData = textRenderData;
    }

    public Map<String, MyPicture> getPictureRenderData() {
        return pictureRenderData;
    }

    public void setPictureRenderData(Map<String, MyPicture> pictureRenderData) {
        this.pictureRenderData = pictureRenderData;
    }

    public Map<String, List<Map<String, String>>> getTableRenderData() {
        return tableRenderData;
    }

    public void setTableRenderData(Map<String, List<Map<String, String>>> tableRenderData) {
        this.tableRenderData = tableRenderData;
    }

    public RenderData addText(String key, String value) {
        textRenderData.put(key, value);
        return this;
    }

    public RenderData addPicture(String key, MyPicture value) {
        pictureRenderData.put(key, value);
        return this;
    }

    public RenderData addPicture(String key, String path, Integer width, Integer height) {
        pictureRenderData.put(key, new MyPicture(path, width, height));
        return this;
    }

    public RenderData addTable(String key, List<Map<String, String>> value) {
        tableRenderData.put(key, value);
        return this;
    }

    public RenderData addTableRow(String key, Map<String, String> value) {
        if (tableRenderData.get(key) == null) {
            tableRenderData.put(key, new ArrayList<>());
        }
        tableRenderData.get(key).add(value);
        return this;
    }

    public RenderData addTableRow(String key, TableRows rows) {
        if (tableRenderData.get(key) == null) {
            List<Map<String, String>> newRow = new ArrayList<>();
            tableRenderData.put(key, newRow);
        }
        Map<String, String> row = new HashMap<>();
        rows.add(row);
        tableRenderData.get(key).add(row);
        return this;
    }



}
